package o;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.drawable.GradientDrawable;
import android.util.Log;
import com.huawei.hwphy2d.physical.util.BarrierParameters;
import huawei.hwanimation.CubicBezierInterpolator;

public class fpm extends GradientDrawable {
    private float ʻ;
    private float ʼ;
    private float ʽ;
    private TimeInterpolator ˊ;
    private Animator ˋ;
    private boolean ˋॱ;
    private Animator ˎ;
    private float ˏ;
    private boolean ॱ;
    private float ॱॱ;
    private float ᐝ;

    public fpm() {
        this(201326592, 1.0f, 12.0f);
    }

    public fpm(int i, float f, float f2) {
        this.ˊ = new CubicBezierInterpolator(BarrierParameters.FRICTION, 0.0f, 0.4f, 1.0f);
        ˎ(i, f, f2);
    }

    public fpm(Context context) {
        this(201326592, 1.0f, context);
    }

    public fpm(int i, float f, Context context) {
        this(i, f, 4.0f, context);
    }

    public fpm(int i, float f, float f2, Context context) {
        this.ˊ = new CubicBezierInterpolator(BarrierParameters.FRICTION, 0.0f, 0.4f, 1.0f);
        if (context != null) {
            ˎ(i, f, context.getResources().getDisplayMetrics().density * f2);
        } else {
            ˎ(i, f, 12.0f);
        }
    }

    private void ˎ(int i, float f, float f2) {
        setShape(0);
        setColor(i);
        setCornerRadius(f2);
        this.ᐝ = f2;
        this.ॱ = false;
        this.ˏ = f;
        this.ʼ = 0.0f;
        this.ॱॱ = 1.0f;
        this.ʽ = 0.9f;
        this.ˋॱ = false;
    }

    public void ॱ(float f) {
        if (f >= 0.0f && f <= 1.0f) {
            this.ˏ = f;
        }
    }

    public void ˊ(float f) {
        if (f >= 0.0f && f <= 1.0f) {
            this.ॱॱ = f;
        }
    }

    public void ˋ(float f) {
        if (f >= 0.0f && f <= 1.0f) {
            this.ʽ = f;
        }
    }

    public float ˎ() {
        return this.ʼ;
    }

    public void ˎ(float f) {
        if (f >= 0.0f && f <= 1.0f) {
            this.ʻ = f;
            invalidateSelf();
        }
    }

    public void ॱ(boolean z) {
        this.ˋॱ = z;
    }

    public void draw(Canvas canvas) {
        float f = this.ʼ;
        if (f >= 1.0E-7f) {
            float f2 = this.ʻ;
            setAlpha((int) (f * 255.0f));
            canvas.save();
            canvas.scale(f2, f2, ((float) canvas.getWidth()) * 0.5f, ((float) canvas.getHeight()) * 0.5f);
            super.draw(canvas);
            canvas.restore();
        }
    }

    protected boolean onStateChange(int[] iArr) {
        boolean z = false;
        boolean z2 = false;
        for (int i : iArr) {
            if (i == 16842910) {
                z = true;
            } else if (i == 16842919) {
                z2 = true;
            } else {
                Log.i("HwAnimatedGradientDrawable", "State = " + i);
            }
        }
        if (z && r2) {
            z = true;
        } else {
            z = false;
        }
        ˏ(z);
        return true;
    }

    private void ˏ(boolean z) {
        if (this.ॱ != z) {
            this.ॱ = z;
            if (z) {
                if (this.ˋ == null || !this.ˋ.isRunning()) {
                    if (this.ˎ != null && this.ˎ.isRunning()) {
                        this.ˎ.cancel();
                    }
                    ˏ();
                }
            } else if (this.ˎ == null || !this.ˎ.isRunning()) {
                if (this.ˋ != null && this.ˋ.isRunning()) {
                    this.ˋ.cancel();
                }
                ˊ();
            }
        }
    }

    public boolean setVisible(boolean z, boolean z2) {
        boolean visible = super.setVisible(z, z2);
        if (!z) {
            ॱ();
        } else if (!visible) {
            Log.i("HwAnimatedGradientDrawable", "isChanged = " + visible);
        } else if (this.ॱ) {
            this.ʼ = this.ˏ;
            this.ʻ = this.ॱॱ;
        } else {
            this.ʼ = 0.0f;
        }
        return visible;
    }

    private void ॱ() {
        if (this.ˋ != null && this.ˋ.isRunning()) {
            this.ˋ.end();
        }
        if (this.ˎ != null && this.ˎ.isRunning()) {
            this.ˎ.end();
        }
        this.ˋ = null;
        this.ˎ = null;
        this.ॱ = false;
        this.ʼ = 0.0f;
        invalidateSelf();
    }

    private void ˏ() {
        Animator animatorSet = new AnimatorSet();
        Animator ofFloat = ObjectAnimator.ofFloat(this, "rectAlpha", new float[]{this.ˏ});
        ofFloat.setDuration(100);
        ofFloat.setInterpolator(this.ˊ);
        if (this.ᐝ > 0.0f || this.ˋॱ) {
            Animator ofFloat2;
            if (ˎ() < 1.0E-7f) {
                ofFloat2 = ObjectAnimator.ofFloat(this, "rectScale", new float[]{this.ʽ, this.ॱॱ});
            } else {
                ofFloat2 = ObjectAnimator.ofFloat(this, "rectScale", new float[]{this.ॱॱ});
            }
            ofFloat2.setDuration(100);
            ofFloat2.setInterpolator(this.ˊ);
            animatorSet.playTogether(new Animator[]{ofFloat, ofFloat2});
        } else {
            ˎ(1.0f);
            animatorSet.play(ofFloat);
        }
        this.ˋ = animatorSet;
        this.ˋ.start();
    }

    private void ˊ() {
        Animator animatorSet = new AnimatorSet();
        Animator ofFloat = ObjectAnimator.ofFloat(this, "rectAlpha", new float[]{0.0f});
        ofFloat.setDuration(100);
        ofFloat.setInterpolator(this.ˊ);
        animatorSet.playTogether(new Animator[]{ofFloat});
        this.ˎ = animatorSet;
        this.ˎ.start();
    }

    public void getOutline(Outline outline) {
        outline.setRect(getBounds());
        outline.setAlpha(0.0f);
    }

    public boolean isStateful() {
        return true;
    }
}
